********************************************************************************
** 	TITLE: e24_cfs_pos_neg_neutral.do

**	PROJECT: IGNITE
** 
**  PURPOSE: Appendix Figure XXIV: Custody Staff Views on Education Programs 
**		in Jail by IGNITE Exposure

********************************************************************************
		set sortseed 13

use "$output_data/IGNITE_corrections_survey_clean.dta", clear

gen d_female = 1-d_male

gen treatment = d_contact
gen post = !d_work_preignite
la var post "Started Work after IGNITE"
la var d_postcovid "Started Work after Covid"
la var d_female "Female"

local covs  d_female d_black  d_age_1 d_age_2 d_age_3 d_age_4 d_age_5 d_age_6 post d_postcovid


gen mi_any = 0
foreach var in `covs'{
	replace `var' = -99 if `var' == .
	replace mi_any = 1 if `var' == -99 
}


keep if !mi_any

la var d_work_inmates_2 "Educ. Programs Worth Time \& Money"


/****************************
bar plot
*****************************/
	ren (d_work_inmates_2 d_work_inmates_2_neg d_work_inmates_2_neu) ///
	 (d_work_inmates_2_p d_work_inmates_2_n d_work_inmates_2_nt)
	
	foreach type in n p nt {
		reg d_work_inmates_2_`type' d_contact i.survey_month, r
		lincom d_contact
		local pval_`type': di %8.3f r(p)
		local pval_`type' = subinstr("`pval_`type''"," ","",.)
		margins, at(d_contact=(0(1)1))
		mat M`type'=r(table)'
	}
	
	preserve
	
		svmat Mp 
		svmat Mn
		svmat Mnt

		keep Mp1 Mp5 Mp6 Mn1 Mn5 Mn6 Mnt1 Mnt5 Mnt6
		gen post = _n-1
		gen post2 = post+3
		gen post3 = post2+3
		
		
		keep if !mi(Mp1)
		
		tw (bar Mp1 post if post, fc(green*.7) lc(%0)) (rcap Mp5 Mp6 post if post, lc(black)) ///
			(bar Mp1 post if !post, fc(navy*1.2) lc(%0)) (rcap Mp5 Mp6 post if !post, lc(black)) ///
			(bar Mn1 post2 if post, fc(green*.7) lc(%0)) (rcap Mn5 Mn6 post2 if post, lc(black)) ///
			(bar Mn1 post2 if !post, fc(navy*1.2) lc(%0)) (rcap Mn5 Mn6 post2 if !post, lc(black)) ///
			(bar Mnt1 post3 if post, fc(green*.7) lc(%0)) (rcap Mnt5 Mnt6 post3 if post, lc(black)) ///
			(bar Mnt1 post3 if !post, fc(navy*1.2) lc(%0)) (rcap Mnt5 Mnt6 post3 if !post, lc(black)) ///
			(scatteri .9 -.5 .875 -.5 , recast(line) lwidth(medium) lp(solid) lc(black)) ///
			(scatteri .9 1.5 .875 1.5 , recast(line) lwidth(medium) lp(solid) lc(black)) ///
			(scatteri .9 -.5 .9 1.5 , recast(line) lwidth(medium) lp(-.) lc(black)) ///
			(scatteri .41 2.5 .385 2.5 , recast(line) lwidth(medium) lp(solid) lc(black)) ///
			(scatteri .41 4.5 .385 4.5 , recast(line) lwidth(medium) lp(solid) lc(black)) ///
			(scatteri .41 2.5 .41 4.5 , recast(line) lwidth(medium) lp(-.) lc(black)) ///
			(scatteri .775 5.5 .75 5.5 , recast(line) lwidth(medium) lp(solid) lc(black)) ///
			(scatteri .775 7.5 .75 7.5 , recast(line) lwidth(medium) lp(solid) lc(black)) ///
			(scatteri .775 5.5 .77 7.5 , recast(line) lwidth(medium) lp(-.) lc(black)) ///
			, xscale(range(-1 8)) legend(off) ///
			xtitle("IGNITE exposure") ///
			ylab(0(.25)1) yscale(range(-.025 1)) ///
			text(.97 .5 "Share agree", size(*.8)) ///
			text(.93 .5 "{it:p}-value = `pval_p'", size(*.8)) ///
			text(.48 3.5 "Share disagree", size(*.8)) ///
			text(.44 3.5  "{it:p}-value = `pval_n'", size(*.8)) ///
			text(.845 6.5 "Share neutral", size(*.8)) ///
			text(.805 6.5  "{it:p}-value = `pval_nt'", size(*.8)) ///
			ytitle("Educ. programs in jail are worth time and money") ///
			xlab( 0 "Low" 1 "High" 3 "Low" 4 "High" 6 "Low" 7 "High", labsize(*.65))
			
	gr export "$figures/survey_pos_neg_neutral.pdf", replace
	
	restore









